package leetcode.tree;

import leetcode.tree.common.TreeNode;

/**
 * @author mazouri
 * @create 2021-05-03 23:30
 */
public class _226_invertTree {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) return null;
        if (root.left == null && root.right == null) return root;

        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;

        invertTree(root.left);
        invertTree(root.right);
        return root;
    }
}
